from typing import *


class Solution:

    def canSeePersonsCount(self, heights: List[int]) -> List[int]:
        ans = [0] * len(heights)
        s = []
        for i in range(len(heights) - 1, -1, -1):
            c = 0
            while len(s) > 0 and heights[i] > s[-1]:
                c += 1
                s.pop(-1)
            c += len(s) > 0
            s.append(heights[i])
            ans[i] = c
        return ans